import java.util.List;
import java.util.Stack;
import java.util.Vector;

public class k_combination 
{
	private Stack<Character> stack;
	
	private void k_combination_proceedure (List<Character> set, int k) {
		if (k == 1) {
			System.out.println ("Finishing  with " + set);
			for (Character c : set) {
//				this.stack.push(c);
			}
		} else
			for (int i = 0; i <= (set.size() - k); i++) {
				System.out.println ("Recursive call on: " + set.get(i));
				this.stack.push(set.get(i));
				k_combination_proceedure(set.subList(i+1, set.size()), k-1);
			}
	}
	
	public void print_stack () {
		for (Character e : this.stack)
			System.out.print (e + " ");
	}
	
	public k_combination(List<Character> set, int k) {
		this.stack = new Stack<Character>();
		this.k_combination_proceedure(set, k);
	}

	
	public static void main (String args[]) {
		List<Character> set = new Vector<Character>();
		set.add('a');
		set.add('b');
		set.add('c');
		set.add('d');
		set.add('e');
		
		if (args.length != 1) {
			System.err.println ("usage: java k_combination INTEGER");
			System.exit (-1);
		}
				
		long time = System.currentTimeMillis();
		k_combination prototype = new k_combination(set, Integer.parseInt(args[0]));
		time = System.currentTimeMillis() - time;
		
//		prototype.print_stack();
		System.out.println("\nTime: " + time);
	}
	
}
